package com.yic.module.device.dal.mysql.refund;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.device.dal.dataobject.refund.RefundDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.device.controller.admin.refund.vo.*;

/**
 * 退还申请 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface RefundMapper extends BaseMapperX<RefundDO> {

    default PageResult<RefundDO> selectPage(RefundPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RefundDO>()
                .eqIfPresent(RefundDO::getCode, reqVO.getCode())
                .eqIfPresent(RefundDO::getApprove, reqVO.getApprove())
                .eqIfPresent(RefundDO::getDeviceId, reqVO.getDeviceId())
                .betweenIfPresent(RefundDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(RefundDO::getId));
    }

    default List<RefundDO> selectList(RefundExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<RefundDO>()
                .eqIfPresent(RefundDO::getCode, reqVO.getCode())
                .eqIfPresent(RefundDO::getApprove, reqVO.getApprove())
                .eqIfPresent(RefundDO::getDeviceId, reqVO.getDeviceId())
                .betweenIfPresent(RefundDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(RefundDO::getId));
    }

    default RefundDO selectByCode(String code) {
        return selectOne(new LambdaQueryWrapperX<RefundDO>()
                .eq(RefundDO::getCode, code));
    }
}
